<template>
  <kit-page :title="title" :desc="desc" :routes="parentArr" :loading="loading" :padding="padding">

    <!--搜索表单-->
    <kit-search-form :model="condition" @search="doSearch" @toggle="doCalcTableHeight">
    <#list queryList as field>
      <kit-search-item label="${field.comment}">
        <el-input v-model="condition.${field.javaColumName}" clearable></el-input>
      </kit-search-item>
    </#list>
    </kit-search-form>

    <kit-space divider>
      <el-button type="primary" @click="doAdd()">新 增</el-button>
      <el-button @click="doRefresh()">刷 新</el-button>
    </kit-space>

    <!--表格数据-->
    <el-table
      ref="myTable"
      :data="data"
      :height="tableHeight"
      :row-class-name="tableRowClassName"
      border
      tooltip-effect="dark"
    >
      <el-table-column label="编号" type="index" width="50" align="center"></el-table-column>
      <#list columnsList as field>
      <el-table-column label="${field.comment}" prop="${field.javaColumName}" align="center"></el-table-column>
      </#list>
      <el-table-column label=" " fixed="right" :width="actionColumnWidth" align="center">
        <template slot-scope="scope">
          <el-button v-permission="'SystemRoleEdit'" type="text" @click="doEdit(scope.row)">
            编辑
          </el-button >
          <el-button v-permission="'SystemRoleDelete'" type="text" @click="doDelete(scope.row)">
            删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>

    <!--分页栏-->
    <el-pagination
      slot="footer"
      @size-change="doSizeChange"
      @current-change="doCurrentChange"
      :current-page="pagination.currentPage"
      :page-sizes="pagination.pageSizes"
      :page-size="pagination.pageSize"
      :total="pagination.total"
      background
      layout="total, sizes, prev, pager, next, jumper"
    ></el-pagination>
  </kit-page>
</template>

<script>
import TableMixin from 'kitframe-web/mixins/tablePage';

export default {
  name: '${entity}List',
  mixins: [TableMixin],
  data() {
    return {
      loadMethod: this.$api.${module}.getList,
    };
  },
  methods: {
    doAdd() {
      this.doJumpPage('/system/${module}/System${entity}Add');
    },
    doEdit(row) {
      this.doJumpPage('/system/${module}/System${entity}Edit', {
        id: row.id,
      });
    },
    doDelete(row) {
      this.doElConfirm(`此操作将删该条记录, 是否继续?`).then(() => {
        this.$api.${module}.deleteRow(row.id).then(() => {
          this.$message({
            message: '删除成功!',
            type: 'success',
          });
          this.doReload();
        });
      });
    },
  },
};
</script>

<style lang="scss" scoped>
</style>
